package com.github.zyf.ioaj.annotation.processor;

import com.github.zyf.ioaj.algorithm.Function;
import com.github.zyf.ioaj.constant.AlgorithmType;
import com.github.zyf.ioaj.constant.ExportType;
import com.github.zyf.ioaj.annotation.external.ObjectFunction;
import com.github.zyf.ioaj.constant.FileType;

/**
 * <h1>目标函数结点</h1>
 * <p>该类用于解析{@link ObjectFunction}注解用，收集被注解的函数相关信息，方便进一步解析</p>
 *
 * @author zyf
 */
public class ObjectFunctionNode {

    private final AlgorithmType algorithmType;
    private final int varNum;
    private final double[] lb;
    private final double[] ub;
    private final Function function;
    private ExportInfo export;

    private boolean isExported;

    public ObjectFunctionNode(AlgorithmType algorithmType, int varNum, double[] lb, double[] ub, Function function) {
        this.algorithmType = algorithmType;
        this.varNum = varNum;
        this.lb = lb;
        this.ub = ub;
        this.function = function;
        this.isExported = false;
    }

    public ObjectFunctionNode(AlgorithmType algorithmType, int varNum, double[] lb, double[] ub, Function function, ExportInfo export) {
        this.algorithmType = algorithmType;
        this.varNum = varNum;
        this.lb = lb;
        this.ub = ub;
        this.function = function;
        this.isExported = true;
        this.export = export;
    }

    public AlgorithmType algorithmType() {
        return algorithmType;
    }

    public int varNum() {
        return varNum;
    }

    public double[] lb() {
        return lb;
    }

    public double[] ub() {
        return ub;
    }

    public Function function() {
        return function;
    }

    public boolean isExported() {
        return isExported;
    }

    public void setExported() {
        isExported = true;
    }

    public ExportInfo getExport() {
        return export;
    }

    public static class ExportInfo {
        private final String author;
        private final String message;
        private final String title;
        private final ExportType exportType;
        private final FileType fileType;

        public ExportInfo(String author, String message,String title, ExportType exportType, FileType fileType) {
            this.author = author;
            this.message = message;
            this.title = title;
            this.exportType = exportType;
            this.fileType = fileType;
        }

        public String getAuthor() {
            return author;
        }

        public String getMessage() {
            return message;
        }

        public String getTitle() {
            return title;
        }

        public ExportType getExportType() {
            return exportType;
        }

        public FileType getFileType() {
            return fileType;
        }
    }
}
